// 市场销售 / 预定管理

import r from '@/utils/request'
import { type ListResponseType, type ResponseType } from '../types'

enum API {
    reservationGet = 'reservation/get',// 获取单条预定信息
    reservationList = "/reservation/list", // 预定列表
    reservationAdd = "/reservation/add", // 预定添加
    reservationUpdate = "/reservation/update", // 预定修改
    reservationDelete = "/reservation/delete", // 预定删除
    reservationDeleteAll = '/reservation/deleteAll' // 预定批量删除
}

export interface reservationGetResFileAPI {
    id:            number;
    reservationId: number;
    file:          string;
    fileName:      string;
}

export interface reservationGetResAPI {
    id:             number;
    companyId:      number;
    elderlyId:      number;
    name:           string;
    mobile:         string;
    relation:       string;
    begId:          number;
    begName:        string;
    startDate:      string;
    day:            number;
    amount:         number;
    addTime:        string;
    addAccountId:   number;
    addAccountName: string;
    elderlyName:    string;
    elderlyPhoto:   string;
    elderlyGender:  string;
    elderlyIdCard:  string;
    houseName:      string;
    buildingName:   string;
    files:          reservationGetResFileAPI[];
}

export function reservationGetAPI(id:number):Promise<ResponseType<reservationGetResAPI>> {
    return r.get( API.reservationGet + '/' + id )
}

export interface reservationListParams {
    page: number
    pageSize: number
    name: string
    idCard: string
    begId: string
    mobile: number
}

export interface reservationListResAPI {
    id:             number;
    companyId:      number;
    elderlyId:      number;
    name:           string;
    mobile:         string;
    relation:       string;
    begId:          number;
    begName:        string;
    startDate:      string;
    day:            number;
    amount:         number;
    addTime:        string;
    addAccountId:   number;
    addAccountName: string;
    elderlyName:    string;
    elderlyPhoto:   string;
    elderlyGender:  string;
    elderlyIdCard:  string;
    houseName:      string;
    buildingName:   string;
    files:          string;
}

export function getreservationListAPI(Params:reservationListParams):Promise<ListResponseType<reservationListResAPI[]>> {
    return r.get(API.reservationList,Params)
}

export interface  reservationAddAndUpdateFileParams {
    file:     string;
    fileName: string;
}

export interface  reservationAddAndUpdateParams {
    id:        number;
    elderlyId: number;
    name:      string;
    mobile:    string;
    relation:  string;
    begId:     number;
    startDate: string;
    day:       number;
    amount:    number;
    files:     reservationAddAndUpdateFileParams[];
}

export interface reservationAddAndUpdateResFileAPI {
    id:            number;
    reservationId: number;
    file:          string;
    fileName:      string;
}

export interface reservationAddAndUpdateResAPI {
    id:             number;
    companyId:      number;
    elderlyId:      number;
    name:           string;
    mobile:         string;
    relation:       string;
    begId:          number;
    begName:        string;
    startDate:      string;
    day:            number;
    amount:         number;
    addTime:        string;
    addAccountId:   number;
    addAccountName: string;
    elderlyName:    string;
    elderlyPhoto:   string;
    elderlyGender:  string;
    elderlyIdCard:  string;
    houseName:      string;
    buildingName:   string;
    files:          reservationAddAndUpdateResFileAPI[];
}

export function reservationAddAPI(Params:reservationAddAndUpdateParams):Promise<ResponseType<reservationAddAndUpdateResAPI>> {
    return r.post(API.reservationAdd,Params)
}

export function reservationUpdateAPI(Params:reservationAddAndUpdateParams):Promise<ResponseType<reservationAddAndUpdateResAPI>> {
    return r.put(API.reservationUpdate,Params)
}

export function reservationDeleteAPI(id:number):Promise<ResponseType<null>> {
    return r.delete(API.reservationDelete+'/'+id)
}
export function reservationDeleteAllAPI(ids:number[]):Promise<ResponseType<null>> {
    return r.post(API.reservationDeleteAll,ids)
}